package com.social.controller;

import com.mzt.logapi.starter.annotation.LogRecord;
import com.social.constant.LogConst;
import com.social.pojo.Evaluate;
import com.social.pojo.Result;
import com.social.service.EvaluateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @author zero
 * @version 1.0
 * @project demo
 * @description 评价
 * @date 2022/12/22 15:15:38
 */
@Api("EvaluateController")
@RestController
@RequestMapping("/evaluate")
@Slf4j
public class EvaluateController {
    @Resource
    private EvaluateService evaluateService;
    //新增评价
    @PostMapping("/add")
    @ApiOperation("新增评价")
    @LogRecord(success = "{{#evaluate.userId}}新增了一条评价,评价打分是{{#evaluate.score}}",
            type = LogConst.PETITION,bizNo = "{{#evaluate.id}}")
    public Result addEvaluate(@Valid @RequestBody Evaluate evaluate){
        return evaluateService.addEvaluate(evaluate);
    }

    //查询历史评价
    @GetMapping("/history")
    @ApiOperation("查询历史评价")
    public Result findHistory(){
        return evaluateService.findHistory();
    }

    //查询没有进行过评价的信访
    @GetMapping("/noeval")
    public Result findNoEval(){
        return evaluateService.findNoEval();
    }

}
